//
//  WPForumTableViewCell.m
//  ZhongChouPingTai
//
//  Created by WeiPan on 16/4/7.
//  Copyright © 2016年 WPJoe. All rights reserved.
//

#import "WPForumTableViewCell.h"

@interface WPForumTableViewCell ()
@property (nonatomic, strong) UILabel * titleLabel;/**< 标题 */
@property (nonatomic, strong) UIImageView * firstImageView;/**< 第一幅图 */
@property (nonatomic, strong) UIImageView * secImageView;/**< 第二幅海报 */
@property (nonatomic, strong) UIImageView * thirdImageView;/**< 第三幅海报 */
@property (nonatomic, strong) UILabel * timeLabel;/**< 时间海报 */
@property (nonatomic, strong) UITextField * attentionTextField;/**< 关注人数 */
@property (nonatomic, strong) UITextField * suppotrTextField;/**< 点赞人数 */
- (void)initializeAppearance;/**< 一般界面初始化 */


@end
@implementation WPForumTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initializeAppearance];
    }
    return self;
}
#pragma mark - init
- (void)initializeAppearance {
    [self addSubview:self.titleLabel];
    [self addSubview:self.firstImageView];
    [self addSubview:self.secImageView];
    [self addSubview:self.thirdImageView];
    [self addSubview:self.timeLabel];
    [self addSubview:self.attentionTextField];
    [self addSubview:self.suppotrTextField];
    UIView * line = [[UIView alloc]initWithFrame:CGRectMake(10*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.timeLabel.frame)-8*DHFlexibleHorizontalMutiplier(), 300*DHFlexibleHorizontalMutiplier(), 0.5)];
    line.backgroundColor = BGCOLOR;
    [self addSubview:line];
}
#pragma mark - 刷新数据
- (void)refreshDataWithModel:(WPForumModel *)model {
    _titleLabel.text = model.title;
    _firstImageView.image = IMAGE_NAME(model.firstImage);
    _secImageView.image = IMAGE_NAME(model.secondImage);
    _thirdImageView.image = IMAGE_NAME(model.thirdImage);
    _timeLabel.text = model.time;
    _attentionTextField.text = model.attentionCount;
    _suppotrTextField.text = model.supportCount;
}
#pragma mark - getter
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = ({
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(10*DHFlexibleHorizontalMutiplier(), 0, 300*DHFlexibleHorizontalMutiplier(), 40*DHFlexibleHorizontalMutiplier())];
            lab.font = [UIFont systemFontOfSize:14*DHFlexibleHorizontalMutiplier()];
            lab.textColor = COLOR_RGB(58, 58, 58, 1);
            lab;
        });
    }
    return _titleLabel;
}
- (UIImageView *)firstImageView {
    if (!_firstImageView) {
        _firstImageView = ({
            UIImageView * view = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 98*DHFlexibleHorizontalMutiplier(), 80*DHFlexibleHorizontalMutiplier())];
            view.center = CGPointMake(59*DHFlexibleHorizontalMutiplier(), 80*DHFlexibleHorizontalMutiplier());
            view.layer.cornerRadius = 3*DHFlexibleHorizontalMutiplier();
            view.layer.masksToBounds = YES;
            view;
        });
    }
    return _firstImageView;
}
- (UIImageView *)secImageView {
    if (!_secImageView) {
        _secImageView = ({
            UIImageView * view = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 98*DHFlexibleHorizontalMutiplier(), 80*DHFlexibleHorizontalMutiplier())];
            view.center = CGPointMake(160*DHFlexibleHorizontalMutiplier(), 80*DHFlexibleHorizontalMutiplier());
            view.layer.cornerRadius = 3*DHFlexibleHorizontalMutiplier();
            view.layer.masksToBounds = YES;
            view;
        });
    }
    return _secImageView;
}
- (UIImageView *)thirdImageView {
    if (!_thirdImageView) {
        _thirdImageView = ({
            UIImageView * view = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 98*DHFlexibleHorizontalMutiplier(), 80*DHFlexibleHorizontalMutiplier())];
            view.center = CGPointMake(261*DHFlexibleHorizontalMutiplier(), 80*DHFlexibleHorizontalMutiplier());
            view.layer.cornerRadius = 3*DHFlexibleHorizontalMutiplier();
            view.layer.masksToBounds = YES;
            view;

        });
    }
    return _thirdImageView;
}
- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = ({
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(10*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.firstImageView.frame), 80, 50*DHFlexibleHorizontalMutiplier())];
            label.textColor = COLOR_RGB(121, 121, 121, 211);
            label.font = [UIFont systemFontOfSize:12*DHFlexibleHorizontalMutiplier()];
            label;
        });
    }
    return _timeLabel;
}
- (UITextField *)attentionTextField {
    if (!_attentionTextField) {
        _attentionTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(200*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.firstImageView.frame), 50*DHFlexibleHorizontalMutiplier(), 46*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UIView * leftview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20*DHFlexibleHorizontalMutiplier(), 46*DHFlexibleHorizontalMutiplier())];
            UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 18.5*DHFlexibleHorizontalMutiplier(), 15*DHFlexibleHorizontalMutiplier(), 9*DHFlexibleHorizontalMutiplier())];
            imageView.image = IMAGE_NAME(@"矢量智能对象.png");
            [leftview addSubview:imageView];
            text.leftView = leftview;
            text.font = [UIFont systemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            text.textColor = COLOR_RGB(121, 121, 121, 1);
            text.userInteractionEnabled = NO;
            text;
        });
    }
    return _attentionTextField;
}
- (UITextField *)suppotrTextField {
    if (!_suppotrTextField) {
        _suppotrTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(260*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.firstImageView.frame), 50*DHFlexibleHorizontalMutiplier(), 46*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UIView * leftview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 17*DHFlexibleHorizontalMutiplier(), 46*DHFlexibleHorizontalMutiplier())];
            UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 16.5*DHFlexibleHorizontalMutiplier(), 12*DHFlexibleHorizontalMutiplier(), 13*DHFlexibleHorizontalMutiplier())];
            imageView.image = IMAGE_NAME(@"iconfont-dianzan-(2).png");
            [leftview addSubview:imageView];
            text.leftView = leftview;
            text.font = [UIFont systemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            text.textColor = COLOR_RGB(121, 121, 121, 1);
            text.userInteractionEnabled = NO;
            text.textAlignment = NSTextAlignmentRight;
            text;

        });
    }
    return _suppotrTextField;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
